const path = require("path"),
    HtmlPlugin = require("html-webpack-plugin"),
    config = {
        entry: {
            index: "./src/index.tsx"
        },
        plugins: [new HtmlPlugin({
            template: "./index.html",
            filename: `index.html`,
            title: '易代理',
            chunks: ["index"],
            minify: {
                removeEmptyAttributes: true,
                removeComments: true,
                minifyCSS: true,
                minifyURLs: true
            }
        })],
        output: {
            filename: "[name].js?v=[hash]",
            path: path.resolve(__dirname, "./dist")
        },
        resolve: {
            extensions: [".tsx", ".ts", ".js"]
        },
        externals: {
            React: "react",
            ReactDOM: "react-dom",
            $: "jquery",
            jQuery: "jquery"
        },
        module: {
            rules: [
                {
                    test: /\.tsx?$/,
                    loader: "ts-loader"
                },
                {
                    test: /\.css(\?.*?)?/,
                    loaders: ["style-loader", "css-loader"]
                },
                {
                    test: /\.less/,
                    loaders: ["style-loader", "css-loader", "less-loader"]
                },
                {
                    test: /\.(ttf|svg|otf|eot|woff|woff2|ogg)(\?.*?)?/,
                    use: [
                        {loader: "file-loader"}
                    ]
                }

            ]
        }
    };
module.exports = config;